/**
 * Created by dale on 2017/10/9.
 */
var articleList;
$(document).ready(function () {
    articleList = $('#articleList');
    $('.xh-datagrid-toolbar').parseToolbar();

    articleList.initDataGrid(baseUrl + 'frontend/article/getArticle');

    $('#bt_list_add').click(function () {
        window.top.xhTop.createNewTab('新增文章',baseUrl+'frontend/article/articleForm?iArtType=1');
    });

    $('#bt_list_del').click(function () {
        var ids = articleList.getDataGridSelectedFields('iArtId');
        myWindow.initPopUp({title: '确定要删除么?', text: '这些车辆将被删除!'},function () {
            $.ajax({
                url:baseUrl+'frontend/article/delArticle',
                data:{ids:ids},
                type:'POST',
                success:function (data) {
                    console.log(data);
                    window.top.swal(
                        data['msg'],
                        '',
                        'success'
                    );
                    articleList.dataGridReload();
                },
                error:function (data) {
                    window.top.swal(
                        data['responseText'],
                        '',
                        'success'
                    );
                }
            });
        });
    });

    DataGrid.onDblClickRow=function (rowIndex, rowData) {
        var iArtId = rowData['iArtId'];
        window.top.xhTop.createNewTab('编辑文章',baseUrl+'frontend/article/articleForm?iArtType=1&iArtId='+iArtId);
        return false;
    }
});